package com.rongxun.hbwallet.ui.activities;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.view.ViewStub;
import android.widget.ImageView;

import com.rongxun.base.BaseActivity;
import com.rongxun.hbwallet.R;

import butterknife.BindView;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/6/12 14:04
 * 描述	      欢迎页
 */

public class SplashActivity extends BaseActivity {


    @BindView(R.id.view_stub)
    ViewStub mViewStub;

    @Override
    protected void init() {
        initAnimate();
    }

    @Override
    protected int getContentView() {
        return R.layout.activity_splash;
    }
    private void initAnimate() {
        mViewStub.setLayoutResource(R.layout.layout_welcom_view);
        mViewStub.inflate();
        ImageView welcomView = (ImageView) findViewById(R.id.splash_iv);
        ObjectAnimator animatorX = ObjectAnimator.ofFloat(welcomView, "scaleX", 1f, 1.13f);
        ObjectAnimator animatorY = ObjectAnimator.ofFloat(welcomView, "scaleY", 1f, 1.13f);

        final AnimatorSet set = new AnimatorSet();
        set.setDuration(2000).play(animatorX).with(animatorY);
        set.start();
        set.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(mainIntent);
                finish();
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            }
        });

    }
}
